package com.feige.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feige.constant.Constants;
import com.feige.dao.ExerciseMapper;
import com.feige.pojo.Exercise;
import com.feige.pojo.vo.ExerciseVo;
import com.feige.result.AjaxResult;
import com.feige.service.ExerciseService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 习题集 服务实现类
 * </p>
 *
 * @author feige
 * @since 2021-04-01
 */
@Service
public class ExerciseServiceImpl extends ServiceImpl<ExerciseMapper, Exercise> implements ExerciseService {


    @Override
    public AjaxResult getExerciseVo(Integer pageNum, String exerciseTitleId, String userId) {
        IPage<ExerciseVo> page = new Page<>(pageNum, Constants.PAGE_SIZE * 4);
        this.baseMapper.getExerciseVo(page,exerciseTitleId,userId);
        AjaxResult success = AjaxResult.success(page.getRecords());
        success.put("total",page.getTotal());
        return success;
    }
}
